Handling Unexpected Application Errors in Windows

When running an APL application, it is possible that an unexpected error will occur.

It is advisable to set a trap at the top level of the application which traps all possible errors; in this way the programmer can cater for any errors that are not already explicitly trapped by, for example, writing information to a file, or saving the workspace. On UNIX in particular it may also be useful to call ⎕OFF with a positive integer to the right of the ⎕OFF - this is used as the exit code to APL.

It is also possible to generate an error which it is not possible to trap in APL code; examples include attempting to access the session in a runtime APL, or generating an error which causes APL to crash (for example, by the incorrect use of a shared library function).

By default in such cases, APL will pop up a message box, and cannot continue until the user selects the OK button.

It is possible to override this behaviour by setting the configuration parameter DYALOG_NOPOPUPS to 1. This will cause system popups to be suppressed; it does not suppress application popups generated by APL code.

With DYALOG_NOPOPUPS=1 APL will terminate silently, except that an aplcore file will be generated. The location of the aplcore file can be controlled by the configuration parameter APLCoreName. It may be more useful to ask the operating system to handle the unexpected termination of the APL process, for example, by bringing up a debugger, or Dr Watson. This can be achieved by setting the configuration parameter PassExceptionsToOpSys to 1. In most cases it is useful to set DYALOG_NOPOPUPS=1 too.

It is also possible to log such events to the Windows Event Log. Setting the configuration parameter DYALOG_EVENTLOGGINGLEVEL to a value greater than 0 will cause this to happen. If the configuration parameter DYALOG_EVENTLOGNAME is not set, then an event log called Dyalog will be created which can be viewed from the Windows Event Viewer. The first time that such an event occurs the following entries will be added to the Windows registry:

The key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Dyalog APL with values

Value Name Value
Sources Dyalog APL
MaxSize 150000000

The key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Dyalog APL\Dyalog APL with values

Value Name Value
EventMessageFile DYALOG\dyalog.exe
CategoryMessageFile DYALOG\dyalog.exe
Category Count 5
TypesSupported 7

where DYALOG is the directory where Dyalog APL is installed.

If DYALOG_EVENTLOGNAME is set, it should contain the name of the log to which events will be logged. For example

DYALOG_EVENTLOGNAME="MyApp Event Log"

When set, no registry entries are added by Dyalog, but if the above registry entries have been manually created, the events will be logged to an event log which has the name "MyApp Event Log". If the registry entries described above have not been created, the events will instead be logged into the Application Log, and the Event Viewer will display text similar to the following when events are viewed:

The description for Event ID ( 1 ) in Source ( MyApp Event Log ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Syserror: 995 code: 2 Aplcore "aplcore1" has been created.